﻿#include "EditorNotificationModel.h"

#include "EditorNotificationItemModel.h"

void REditorNotificationModel::AddItem(TSharedObjectPtr<REditorNotificationItemModel> InItem)
{
    InItem->SetOwner(this);
    Items.Add(InItem);

    if(!bDontDisturb && Visibility==EVisibility::NoneVisible)
    {
        Visibility = EVisibility::LastVisible;
    }

    OnItemsChanged.ExecuteIfBound();
}

void REditorNotificationModel::RemoveItem(TSharedObjectPtr<REditorNotificationItemModel> InItem)
{
    Items.Remove(InItem);
    OnItemsChanged.ExecuteIfBound();
}

void REditorNotificationModel::ClearItems()
{
    Items.Empty();
    OnItemsChanged.ExecuteIfBound();
}

bool REditorNotificationModel::IsTitleVisible() const
{
    return Visibility == EVisibility::AllVisible;
}

void REditorNotificationModel::ToggleNotificationVisible()
{
    if(Visibility == EVisibility::AllVisible)
    {
        Visibility = EVisibility::NoneVisible;
    }
    else
    {
        Visibility = EVisibility::AllVisible;
    }
}
